package com.bwie.common.log;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class LogAspect {
    private static final Logger logger = LoggerFactory.getLogger(LogAspect.class);

    @Before("@annotation(log)")
    public void logBeforeMethod(JoinPoint joinPoint, Log log) {
        String methodName = joinPoint.getSignature().getName();
        String title = log.title();
        BusinessType businessType = log.businessType();
        logger.info("方法: {}, 操作标题: {}, 业务类型: {}", methodName, title, businessType);
        // 还可进一步获取方法参数等信息记录日志
        Object[] args = joinPoint.getArgs();
        logger.info("方法参数: {}", args);
    }
}
